package com.laowang.project.system.controller;

import java.util.List;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.laowang.framework.aspectj.lang.annotation.Log;
import com.laowang.framework.aspectj.lang.enums.BusinessType;

import org.springframework.web.bind.annotation.*;
import com.laowang.project.system.domain.MyCyhGroup;
import com.laowang.project.system.service.MyCyhGroupService;
import com.laowang.framework.web.controller.BaseController;
import com.laowang.framework.web.domain.AjaxResult;
import com.laowang.common.utils.poi.ExcelUtil;
import com.laowang.framework.web.page.TableDataInfo;

/**
 * 车友会管理Controller
 *
 * @author laowang
 * @date 2023-04-26
 */
@Api(tags = "车友俱乐部管理接口")
@RestController
@RequestMapping("/carGroup")
public class MyCyhGroupController extends BaseController {
    @Autowired
    private MyCyhGroupService myCyhGroupService;

    @ApiOperation(value = "小程序端 车图标(俱乐部列表)",notes = "")
    @GetMapping("/web/car/icon")
    public AjaxResult carIcon() {
        List<MyCyhGroup> list = myCyhGroupService.selectMyCyhGroupList(null);

        return AjaxResult.success("操作成功",list);
    }

    @ApiOperation(value = "小程序端 俱乐部详情",notes = "")
    @GetMapping("/web/car/{id}")
    public AjaxResult carId(@PathVariable Integer id) {
        MyCyhGroup myCyhGroup = myCyhGroupService.selectMyCyhGroupById(id);

        return AjaxResult.success("操作成功",myCyhGroup);
    }


    /**
     * 查询车友会管理列表
     */
    @ApiOperation(value = "查询车友会管理列表",notes = "")
    @PreAuthorize("@ss.hasPermi('my:carGroup:list')")
    @GetMapping("/list")
        public TableDataInfo list(MyCyhGroup myCyhGroup) {
        startPage();
        List<MyCyhGroup> list = myCyhGroupService.selectMyCyhGroupList(myCyhGroup);
        return getDataTable(list);
    }

    /**
     * 导出车友会管理列表
     */
    @ApiOperation(value = "导出车友会管理列表",notes = "")
    @PreAuthorize("@ss.hasPermi('my:carGroup:export')")
    @Log(title = "车友会管理", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(MyCyhGroup myCyhGroup) {
        List<MyCyhGroup> list = myCyhGroupService.selectMyCyhGroupList(myCyhGroup);
        ExcelUtil<MyCyhGroup> util = new ExcelUtil<MyCyhGroup>(MyCyhGroup.class);
        return util.exportExcel(list, "carGroup");
    }

    /**
     * 获取车友会管理详细信息
     */
    @ApiOperation(value = "获取车友会管理详细信息",notes = "")
    @PreAuthorize("@ss.hasPermi('my:carGroup:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Integer id) {
        return AjaxResult.success(myCyhGroupService.selectMyCyhGroupById(id));
    }

    /**
     * 新增车友会管理
     */
    @ApiOperation(value = "新增车友会管理",notes = "")
    @PreAuthorize("@ss.hasPermi('my:carGroup:add')")
    @Log(title = "车友会管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody MyCyhGroup myCyhGroup) {
        return toAjax(myCyhGroupService.insertMyCyhGroup(myCyhGroup));
    }

    /**
     * 修改车友会管理
     */
    @ApiOperation(value = "修改车友会管理",notes = "")
    @PreAuthorize("@ss.hasPermi('my:carGroup:edit')")
    @Log(title = "车友会管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody MyCyhGroup myCyhGroup) {
        return toAjax(myCyhGroupService.updateMyCyhGroup(myCyhGroup));
    }

    /**
     * 删除车友会管理
     */
    @ApiOperation(value = "删除车友会管理",notes = "")
    @PreAuthorize("@ss.hasPermi('my:carGroup:remove')")
    @Log(title = "车友会管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Integer[] ids) {
        return toAjax(myCyhGroupService.deleteMyCyhGroupByIds(ids));
    }
}
